package com.shiningstars.tools;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.shiningstars.R;
import com.shiningstars.general.Constants;
import com.shiningstars.general.Messages;

public class AdminCenterAdapter extends ArrayAdapter<String> implements Constants, Messages {

	private final Context context;
	private final List<String> adminCenterList;
	private final Map<String, String> unreadMap;

	public AdminCenterAdapter(Context ctx, List<String> list, Map<String, String> unread) {
		super(ctx, R.layout.admin_center_list_layout, list);
		context = ctx;
		adminCenterList = list;
		unreadMap = unread;
	}

	public List<String> getAdminCenterList() {
		return adminCenterList;
	}

	public Map<String, String> getUnreadMap() {
		return unreadMap;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.admin_center_list_layout, parent, false);
		TextView textView = (TextView) rowView.findViewById(R.id.admin_center_list_center_name);

		String adminCenter = adminCenterList.get(position);
		textView.setText(adminCenter);

		String unread = unreadMap.get(adminCenter);
		if (Y.equals(unread)) {
			textView.setTypeface(null, Typeface.BOLD);
		}

		return rowView;
	}
}